using System.Windows.Media;
using CharacterCreation.Data.Models;
using CharacterCreation.Data.Services;
using CharacterCreation.Views.Contracts;
using System.Collections.Generic;
using System.Windows.Input;
using Microsoft.Practices.Prism.Commands;
using System.Windows;

namespace CharacterCreation.Views {
    /// <summary>
    /// Skill detail view model
    /// </summary>
    public partial class SkillDetailViewModel : BaseViewModel {

        SkillService _skillService = SkillService.CreateInstance();

        /// <summary>
        /// The foreground brush
        /// </summary>
        public SolidColorBrush ForegroundBrush {
            get {
                if (!IsNewItem)
                    return new SolidColorBrush(Colors.White);
                else
                    return new SolidColorBrush(Colors.Black);
            }
        }

        /// <summary>
        /// Current race
        /// </summary>
        public Skill Skill {
            get {
                if (!IsNewItem)
                    return _skillService.CurrentItem;
                else
                    return _skillService.NewItem;
            }
        }

        public List<string> statistics {
            get {
                return new List<string>() { "Strength", "Dexterity", "Fighting", "Constitution", "Perception", "Intelligence", "Will power", "Charisma" };
            }
        }

        
        /// <summary>
        /// Gets or sets the IsCollapsed
        /// </summary>
        public Visibility IsCollapsed {
            get {
                if (this.IsNewItem)
                    return Visibility.Visible;
                else
                    return Visibility.Collapsed;
            }
        }
                

        /// <summary>
        /// Adds a statistic from the collection of statistics
        /// </summary>
        public ICommand AddStatisticCommand {
            get { return new DelegateCommand<string>((stat) => { 
                Skill.Statistics.Add(stat); }); 
            }
        }

        /// <summary>
        /// Removes a statistic from teh list of statistics
        /// </summary>
        public ICommand RemoveStatisticCommand {
            get { return new DelegateCommand<string>((stat) => { 
                Skill.Statistics.Remove(stat); }); 
            }
        }

        /// <summary>
        /// ctor
        /// </summary>
        public SkillDetailViewModel() {
            _skillService.PropertyChanged += (s, e) => {
                if (e.PropertyName == "CurrentItem")
                    RaisePropertyChanged("Skill");
            };
        }


    }
}